<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admain/_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>博客管理</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/me.css">
</head>
<body>
<!--导航-->
<nav th:replace="admain/_fragments :: menu(4)" class="ui inverted attached segment m-padded-tb-mini m-shadow-small"><!--Semantic ui 的语句 ui是其中的-->
    <div class="ui container"><!--container一个容器-->
        <div class="ui inverted secondary stackable menu"><!--menu中的每个组件都要item-->
            <h2 class="ui teal header item">管理后台</h2>
            <a href="#" class="m-item item m-mobile-hide"><i class="home icon"></i>博客</a><!--i是引入图标的-->
            <a href="#" class="m-item item m-mobile-hide"><i class="idea icon"></i>分类</a>
            <a href="#" class="m-item item m-mobile-hide"><i class="tags icon"></i>标签</a>
            <div class="right m-item m-mobile-hide menu"><!--菜单-->
                <div class="ui dropdown item"><!--dropdown是一种下拉列表的效果-->
                    <div class="text">
                        <img src="https://picsum.photos/id/1006/100/100"  class="ui avatar image">
                        高胜祥
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="#" class="item">注销</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show">
        <i class="sidebar icon"></i>
    </a>
</nav>
<div class="ui attached pointing menu">
    <div class="ui container">
        <div class="right menu">
            <a href="#" class="item">发布</a>
            <a href="#" class="teal active item">列表</a>
        </div>
    </div>
</div>

<!--中间内容-->
<div class="m-container-small m-padded-tb-big">
    <div class="ui container">
        <!--提交表单-->
        <div class="ui secondary segment form">
            <input type="hidden" name="page"><!--post传入的参数page-->
            <div class="inline fields">
                <div class="field">
                    <input type="text" name="comment_content" placeholder="标题">
                </div>
                <!--单选框-->
                <div class="field">
                    <div class="ui checkbox"><!--选择框-->
                        <input type="checkbox" id="comment_isdelete" name="comment_isdelete">
                        <label for="comment_isdelete">已删除</label>
                    </div>
                </div>
                <div class="field">
                    <button type="button" id="search-btn" class="ui mini teal basic button"><i class="search icon"></i></button>
                </div>
            </div>
        </div>

        <!--表格-->
        <div id="table-container">
            <table th:fragment="commentList" class="ui compact teal table">
                <thead>
                <tr>
                    <th></th>
                    <th>标题</th>
                    <th>类型</th>
                    <th>推荐</th>
                    <th>发布时间</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="comment,iterStat : ${pageInfo.getList()}">
                    <td th:text="${iterStat.count}">1</td>
                    <td th:text="${comment.comment_nickname}">刻意练习清单</td>
                    <td th:text="${comment.comment_email}">认知升级</td>
                    <td th:text="${comment.comment_content}">是</td>
                    <td th:text="${#dates.format(comment.comment_createTime,'yyyy-MM-dd')}">2020-10-02 09:45</td>
                    <td>
                        <a href="#" th:href="@{/admain/comments/{id}/delete(id=${comment.comment_id})}" class="ui mini red basic button">删除</a>
                    </td>
                </tr>
                </tbody>
                <tfoot>
                <tr>
                    <th colspan="6"><!---->
                        <div th:if="${pageInfo.pages}>1" class="ui mini pagination menu">
                            <!--自定义属性-->
                            <a onclick="page(this)" th:attr="data-page=${pageInfo.prePage}" class="icon item" th:unless="${pageInfo.isFirstPage}">上一页</a>
                            <a onclick="page(this)" th:attr="data-page=${pageInfo.nextPage}" class="icon item" th:unless="${pageInfo.isLastPage}">下一页</a>
                        </div>
                    </th>
                </tr>
                </tfoot>
            </table>
            <div class="ui success message" th:unless="${#strings.isEmpty(message)}">
                <i class="close icon"></i>
                <div class="header">提示:</div>
                <p th:text="${message}">恭喜,操作成功</p>
            </div>
        </div>
    </div>
</div>

<br>
    <br>
    <br>
    <br>
    <br>
    <br>

<!--底部footer-->
<footer th:replace="admain/_fragments :: fotter" class="ui inverted attached segment m-padded-tb-massive">
    <div class="ui center aligned container"><!--大的容器-->
        <div class="ui inverted divided stackable grid">
            <div class="three wide column"><!--容器分为16份  three占三份-->
                <div class="ui inverted link list">
                    <div class="item">
                        <img src="../../static/images/wechat.png" class="ui rounded image" alt="" style="width: 110px">
                    </div>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced">最新博客</h4>
                <div class="ui inverted link list m-text-thin m-text-spaced">
                    <a href="#" class="item">用户故事(User Story)</a>
                    <a href="#" class="item">关于刻意练习的清单</a>
                    <a href="#" class="item">失败要趁早</a>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced">最新博客</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">Email:403631975@qq.com</a>
                    <a href="#" class="item">QQ:403631975</a>
                </div>
            </div>
            <div class="seven wide column">
                <h4 class="ui inverted header">Lirenmi</h4>
                <p class="m-text-thin m-text-spaced m-opacity-mini">这是我的个人博客</p>
            </div>
        </div>
        <div class="ui inserted section divider"></div>
        <p class="m-text-thin m-text-spaced m-opacity-mini m-text-lined">Copyright ⚪ 2020 - 2021 Lirenmi Designed by Lirenmi</p>
    </div>
</footer>
<!--/*/<th:block th:replace="admain/_fragments :: script">/*/-->
<script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.js"></script>
<!--/*/</th:block>/*/-->
<script>
    $('.menu.toggle').click(function (){
        $('.m-item').toggleClass('m-mobile-hide');
    });

    $('.message .close').on('click',function (){
        $(this).closest('.message').transition('fade');
    })

    $('.ui.dropdown').dropdown();/*触发dropdown事件的js*/
    /*将值传递给name位page的属性*/
    /*传输数据向后端*/
    function page(obj){
        $("[name='page']").val($(obj).data("page"));
        loaddata();
    }
    $("#search-btn").click(function (){
        loaddata();
    });
    function loaddata(){
        $("#table-container").load("/admain/comments/search",{
            comment_content : $("[name='comment_content']").val(),
            comment_isdelete : $("[name='comment_isdelete']").prop('checked'),
            page : $("[name='page']").val()
        });
    };

    /*清除按钮*/
    $('#clear').on('click',function (){
        $('.ui.type.dropdown').dropdown('clear');
    });
</script>
</body>
</html>